<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png">
    <nav>
      <router-link to="/public-activities">公开活动列表</router-link>
      <router-link v-if="isAuthenticated && role === 'admin'" to="/activity-management">活动管理</router-link>
      <button @click="logout">退出登录</button>
    </nav>
  </div>
</template>

<script>
export default {
  computed: {
    isAuthenticated() {
      return !!localStorage.getItem('role');
    },
    role() {
      return localStorage.getItem('role');
    }
  },
  methods: {
    logout() {
      localStorage.removeItem('role');
      this.$router.push('/login');
    }
  }
};
</script>